<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#--引入外部文件-->
    <#include "../common/header.ftl">

    <script type="application/javascript">
        $(function () {
            $(".deleteCatalogBtn").click(function () {
                var id=$(this).data("ccid");
                $.get("/commodityCatalog/delete.do",{id:id},function (data) {
                    if (data.success){
                        location.reload();
                    }
                })
            })

            $(".modifyBtn").click(function () {
                $("#inputModal").modal('show');
            })
        })

    </script>
</head>
<body>

<div class="container" style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">商品分类管理</h1>
                </div>
            </div>
            <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/commodityCatalog/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <a href="javascript:" class="btn btn-success modifyBtn">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </a>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>商品分类标题</th>
                    <th></th>
                </tr>
                <#--使用Freemark的指令完成循环迭代-->
                <#list (pageInfo.list)! as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.title!}</td>
                        <td>
                            <a href="javascript:" class="btn btn-info btn-xs deleteCatalogBtn" data-ccid='${entity.id!}'>
                                <span class="glyphicon glyphicon-pencil"></span> 删除
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>

            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<#--添加/修改商品-->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        <#--模态框标题-->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">新增/编辑</h4>
            </div>
        <#--模态框正文-->
            <div class="modal-body">
            <#--填充编辑界面-->
                <form class="form-horizontal" action="/commodityCatalog/save.do" method="post" id="editForm">
                    <input type="hidden" name="id"/>

                    <div class="form-group" >
                        <label class="col-lg-4 control-label">名称：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="title" />
                        </div>
                    </div>
                </form>
            </div>
            <#--模态框底部按钮-->
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>